#!/bin/sh

#
# start input-handler
#

# disable by default
#ap_en0=input-handler
#filepath0=/usr/bin/$ap_en0

#if [ -e $filepath0 ];
#then
#        echo "input handler started." > /dev/ttyUSI0
#        $filepath0 &
#        sleep 1s
#else
#        echo "$ap_en0 file not found." > /dev/ttyUSI0
#fi


#mount -o remount,rw /
#rm -rf /tmp.log

#for MTP+HID mode
#sh /usr/bin/mtp_hid.sh -usb3
#sleep 2
#sh /usr/bin/fwupdate_extra.sh //this script move to HID 0x01 0xFF to execute

#for HID mode
#sh /usr/bin/hid.sh -usb3 -s1
#sleep 2

#
# Start the XX if it exist at SD card
#
app_file=app_file
mount_point=/run/SD/mmcblk0p1
start_file=$mount_point/$app_file
for j in 0 1 2
do
#        find_mount_point=$(mount | grep $mount_point | cut -d " " -f3)
#    if [ -d $mount_point ]; then
                if [ -f "$start_file" ]; then
                        echo "app_file found! start to run"
                        $start_file
			break
                fi
#    fi
    sleep 1s
    if [ $j == 2 ]; then
        echo "no app_file found!"
    fi
done

# mark it to go through below code
# exit $?



#
# run apmode to enable m10v ap mode.
#

#ap_en1=apmode
#filepath1=/usr/bin/$ap_en1

#if [ -e $filepath1 ];
#then
#	echo "try to enable ap mode" > /dev/ttyUSI0
#	$filepath1
#else
#	echo "$ap_en1 file not found" > /dev/ttyUSI0
#fi


#
# start input-handler
#

#ap_en0=input-handler
#filepath0=/usr/bin/$ap_en0

#if [ -e $filepath0 ];
#then
#        echo "start input handler" > /dev/ttyUSI0
#        $filepath0 &
#        sleep 1s
#else
#        echo "$ap_en0 file not found" > /dev/ttyUSI0
#fi
echo "-----luke0043 up app---------"
ap_en0=shareapp
filepath0=/usr/bin/$ap_en0

if [ -e $filepath0 ];
then
        echo "luke0043 appfile started." > /dev/ttyUSI0
        $filepath0 &
        sleep 1s
else
        echo "$ap_en0 file not found." > /dev/ttyUSI0
fi
